import cn.hutool.core.lang.ObjectId;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.constant.RedisConstant;
import org.jeecg.modules.shiro.WxUserToken;
import org.jeecg.modules.wechat.entity.WxUser;
import org.junit.jupiter.api.Test;

import java.io.UnsupportedEncodingException;
import java.time.LocalDate;
import java.util.UUID;

/**
 * TODO:
 *
 * @author Zhang Hao yu
 * @date 2020/11/12 21:57
 */
public class Demo {
    @Test
    public void testShiro() {
        WxUser wxUser = new WxUser();
        wxUser.setOpenId("oTIsZ49PCF8TKFmKZbjPXfiAYiBE");
        WxUserToken token = new WxUserToken(wxUser);

        SecurityUtils.getSubject().login(token);
    }

    @Test
    public void testUUID(){
        System.out.println(ObjectId.next());
        Snowflake snowflake = IdUtil.createSnowflake(1,1);
        System.out.println(snowflake.nextIdStr());
        System.out.println(UUID.randomUUID());
    }

    @Test
    public void testTime(){
        String key = RedisConstant.USER_SIGN+ (LocalDate.now()).toString();
        System.out.println(key);
    }
    @Test
    public void testLong(){
        String key = "1328993134036393986";
        Long a = Long.valueOf(key);
        System.out.println(a);
    }

    @Test
    public void testGetImg() throws UnsupportedEncodingException {
        byte[] b = {'d','G','V','t','c','C','9','l','b','G','V','i','Y','W','5','k',
                'X','z','E','2','M','D','I','1','N','z','M','z','N','D','g','z','M','T','M',
                'u','c','G','5','n'};
        String s = new String(b, "UTF-8");
        System.out.println(s);
    }

    @Test
    public void  test2(){
        String hostIP="localhost";
        String userName = "root";
        String passWord = "root";
        String databaseName = "bilibili";
        String savePath = "F:/backup";
        String fileName = "bilibili";
        String fPath = "F:/backup/bilibili.sql";

//        backup(savePath,fileName,hostIP,userName,passWord,databaseName);
//        load(fPath,hostIP,userName,passWord,databaseName);
    }

    @Test
    public void test3(){
        String a = null;
        System.out.println(StringUtils.isEmpty(a));
    }
}